package com.aop.aop_annotation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAop {

    @Pointcut("execution(* com.aop.aop_annotation.UserService.insertUser(..))")
    public void ponitCut() {

    }

    @Before("ponitCut()")
    public void beforeAdvice() {
        System.out.println("beforeAdvice");
    }

    @After("ponitCut()")
    public void afterAdvice() {
        System.out.println("afterAdvice");
    }

    //环绕通知。注意要有ProceedingJoinPoint参数传入
    @Around("ponitCut()")
    public void around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("注解类型环绕通知..环绕前");
        pjp.proceed();//执行方法
        System.out.println("注解类型环绕通知..环绕后");
    }
}